package com.compty.paint.domain;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * @Todo:订单
 * @author: zhuqh
 * @CreateTime:2011-6-2 上午10:18:30
 */
@Entity
@Table(name = "t_order")
public class Order implements java.io.Serializable{

	private static final long serialVersionUID = -6073440219313792445L;
	
	private Integer id;
	
	/************ 订单号 ****************/
	private String sequenceNo;
	
	/************ 下单时间 ****************/
	private Date orderTime;
	
	/************ 顾客信息 ****************/
	private CustomerInfo customerInfo;
	
	/************ 订单最后修改时间 ****************/
	private Date modifyTime;
	
	/************ 订单明细 ****************/
	private List<OrderItem> orderItems = new ArrayList<OrderItem>(0);
	
	private Integer status;//-2至+4,表示订单的各个状态
	private Integer pay_status;//0-4,表示支付的各个状态
	private Integer ship_status;//0-4，表示物流各个状态
	
	//状态显示字串
	private String shipStatus;
	private String payStatus;
	private String orderStatus;
	
	/********* 发票相关信息 begin ***********/
	private String fpFlag;//是否开具发票(1:是 0:否)
	private String fpType;//发票类型：普通发票、增值税发票
	private String fpType2;//发票类型：个人、公司
	private String fpHead;//发票抬头
	/********* 发票相关信息 end ***********/
	
	//收货地区id三级省市的最后一级
	private Integer regionid; 
	private Integer shipping_id; //配送方式
	private String shipping_type; //配送方式
	private String shipping_area;
	private String goods;
	private String ship_name;
	private String ship_addr;
	private String ship_zip;
	private String ship_email;
	private String ship_mobile;
	private String ship_tel;
	private String ship_day;
	private String ship_time;
	private Integer addressInfo_id;//收货地址ID
	private Integer is_protect;//是否保价
	private Double protect_price;//保价金额

	private Double goods_amount;//商品总价
	private Double shipping_amount;//物流总价
	
	private Double discount; //优惠金额
	private Double order_amount;//订单总价
	
	private Double weight;
	private Double paymoney = 0D;//已付款金额
	
	private String remark;//备注
	private Integer disabled;//(1:有效,0:无效)
	
	private String payment_name;//支付方式名称(财付通、支付宝、招商银行等)
	private String payment_type;//支付类型(预付款支付、网银支付、线下支付)
	private Integer goods_num;
	private int gainedpoint;
	private int consumepoint;
	
	private String step;//订单步骤(1:核对订单2：填写收货地址3：选择支付方式4：订购成功收货)

	@Id
	@GeneratedValue
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "sequence_number", length = 40)
	public String getSequenceNo() {
		return sequenceNo;
	}

	public void setSequenceNo(String sequenceNo) {
		this.sequenceNo = sequenceNo;
	}

	@Column(name = "ordertime")
	public Date getOrderTime() {
		return orderTime;
	}

	public void setOrderTime(Date orderTime) {
		this.orderTime = orderTime;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name="customer_id")
	public CustomerInfo getCustomerInfo() {
		return customerInfo;
	}

	public void setCustomerInfo(CustomerInfo customerInfo) {
		this.customerInfo = customerInfo;
	}

	@Column(name = "modifytime")
	public Date getModifyTime() {
		return modifyTime;
	}

	public void setModifyTime(Date modifyTime) {
		this.modifyTime = modifyTime;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "order")
	public List<OrderItem> getOrderItems() {
		return orderItems;
	}

	public void setOrderItems(List<OrderItem> orderItems) {
		this.orderItems = orderItems;
	}

	@Column(name = "status")
	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	@Column(name = "pay_status")
	public Integer getPay_status() {
		return pay_status;
	}

	public void setPay_status(Integer payStatus) {
		pay_status = payStatus;
	}

	@Column(name = "ship_status")
	public Integer getShip_status() {
		return ship_status;
	}

	public void setShip_status(Integer shipStatus) {
		ship_status = shipStatus;
	}

	@Transient
	public String getShipStatus() {
		if(ship_status==0)shipStatus="未发货";
		if(ship_status==1)shipStatus="已发货";
		if(ship_status==2)shipStatus="已退货";
		if(ship_status==3)shipStatus="部分退货";
		if(ship_status==4)shipStatus="部分发货";
		
		return shipStatus;
	}

	public void setShipStatus(String shipStatus) {
		this.shipStatus = shipStatus;
	}

	@Transient
	public String getPayStatus() {
		
		if(pay_status==0)payStatus="未支付";
		if(pay_status==1)payStatus="已支付";
		if(pay_status==2)payStatus="已退款";
		if(pay_status==3)payStatus="部分退款";
		if(pay_status==4)payStatus="部分支付";
		
		return payStatus;
	}

	public void setPayStatus(String payStatus) {
		this.payStatus = payStatus;
	}

	@Transient
	public String getOrderStatus() {
		
		if(status==-2)orderStatus="退货";
		if(status==-1)orderStatus="退款";
		if(status==0)orderStatus="未付款";
		if(status==1)orderStatus="已付款";
		if(status==2)orderStatus="已发货";
		if(status==3)orderStatus="完成";
		if(status==4)orderStatus="作废";
		
		return orderStatus;
	}

	public void setOrderStatus(String orderStatus) {
		this.orderStatus = orderStatus;
	}

	@Column(name = "regionid")
	public Integer getRegionid() {
		return regionid;
	}

	public void setRegionid(Integer regionid) {
		this.regionid = regionid;
	}

	@Column(name = "shipping_id")
	public Integer getShipping_id() {
		return shipping_id;
	}

	public void setShipping_id(Integer shippingId) {
		shipping_id = shippingId;
	}

	@Column(name = "shipping_type")
	public String getShipping_type() {
		return shipping_type;
	}

	public void setShipping_type(String shippingType) {
		shipping_type = shippingType;
	}

	@Column(name = "shipping_area")
	public String getShipping_area() {
		return shipping_area;
	}

	public void setShipping_area(String shippingArea) {
		shipping_area = shippingArea;
	}

	@Column(name = "goods")
	public String getGoods() {
		return goods;
	}

	public void setGoods(String goods) {
		this.goods = goods;
	}

	@Column(name = "ship_name")
	public String getShip_name() {
		return ship_name;
	}

	public void setShip_name(String shipName) {
		ship_name = shipName;
	}

	@Column(name = "ship_addr")
	public String getShip_addr() {
		return ship_addr;
	}

	public void setShip_addr(String shipAddr) {
		ship_addr = shipAddr;
	}

	@Column(name = "ship_zip")
	public String getShip_zip() {
		return ship_zip;
	}

	public void setShip_zip(String shipZip) {
		ship_zip = shipZip;
	}

	@Column(name = "ship_email")
	public String getShip_email() {
		return ship_email;
	}

	public void setShip_email(String shipEmail) {
		ship_email = shipEmail;
	}

	@Column(name = "addressinfo_id")
	public Integer getAddressInfo_id() {
		return addressInfo_id;
	}

	public void setAddressInfo_id(Integer addressInfoId) {
		addressInfo_id = addressInfoId;
	}

	@Column(name = "ship_mobile")
	public String getShip_mobile() {
		return ship_mobile;
	}

	public void setShip_mobile(String shipMobile) {
		ship_mobile = shipMobile;
	}

	@Column(name = "ship_tel")
	public String getShip_tel() {
		return ship_tel;
	}

	public void setShip_tel(String shipTel) {
		ship_tel = shipTel;
	}

	@Column(name = "ship_day")
	public String getShip_day() {
		return ship_day;
	}

	public void setShip_day(String shipDay) {
		ship_day = shipDay;
	}

	
	@Column(name = "ship_time")
	public String getShip_time() {
		return ship_time;
	}

	public void setShip_time(String shipTime) {
		ship_time = shipTime;
	}

	@Column(name = "is_protect")
	public Integer getIs_protect() {
		return is_protect;
	}

	public void setIs_protect(Integer isProtect) {
		is_protect = isProtect;
	}

	@Column(name = "protect_price")
	public Double getProtect_price() {
		return protect_price;
	}

	public void setProtect_price(Double protectPrice) {
		protect_price = protectPrice;
	}

	@Column(name = "goods_amount")
	public Double getGoods_amount() {
		return goods_amount;
	}

	public void setGoods_amount(Double goodsAmount) {
		goods_amount = goodsAmount;
	}

	@Column(name = "shipping_amount")
	public Double getShipping_amount() {
		return shipping_amount;
	}

	public void setShipping_amount(Double shippingAmount) {
		shipping_amount = shippingAmount;
	}

	@Column(name = "discount")
	public Double getDiscount() {
		return discount;
	}

	public void setDiscount(Double discount) {
		this.discount = discount;
	}

	@Column(name = "order_amount")
	public Double getOrder_amount() {
		return order_amount;
	}

	public void setOrder_amount(Double orderAmount) {
		order_amount = orderAmount;
	}

	@Column(name = "weight")
	public Double getWeight() {
		return weight;
	}

	public void setWeight(Double weight) {
		this.weight = weight;
	}

	@Column(name = "paymoney")
	public Double getPaymoney() {
		return paymoney;
	}

	public void setPaymoney(Double paymoney) {
		this.paymoney = paymoney;
	}

	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Column(name = "disabled")
	public Integer getDisabled() {
		return disabled;
	}

	public void setDisabled(Integer disabled) {
		this.disabled = disabled;
	}

	@Column(name = "payment_name",length = 50)
	public String getPayment_name() {
		return payment_name;
	}

	public void setPayment_name(String paymentName) {
		payment_name = paymentName;
	}

	@Column(name = "payment_type",length = 50)
	public String getPayment_type() {
		return payment_type;
	}

	public void setPayment_type(String paymentType) {
		payment_type = paymentType;
	}

	@Column(name = "goods_num")
	public Integer getGoods_num() {
		return goods_num;
	}

	public void setGoods_num(Integer goodsNum) {
		goods_num = goodsNum;
	}

	@Column(name = "gainedpoint")
	public int getGainedpoint() {
		return gainedpoint;
	}

	public void setGainedpoint(int gainedpoint) {
		this.gainedpoint = gainedpoint;
	}

	@Column(name = "consumepoint")
	public int getConsumepoint() {
		return consumepoint;
	}

	public void setConsumepoint(int consumepoint) {
		this.consumepoint = consumepoint;
	}

	@Column(name = "fpflag",length = 20)
	public String getFpFlag() {
		return fpFlag;
	}

	public void setFpFlag(String fpFlag) {
		this.fpFlag = fpFlag;
	}

	@Column(name = "fptype",length = 20)
	public String getFpType() {
		return fpType;
	}

	public void setFpType(String fpType) {
		this.fpType = fpType;
	}

	@Column(name = "fptype2",length = 20)
	public String getFpType2() {
		return fpType2;
	}

	public void setFpType2(String fpType2) {
		this.fpType2 = fpType2;
	}

	@Column(name = "fphead",length = 20)
	public String getFpHead() {
		return fpHead;
	}

	public void setFpHead(String fpHead) {
		this.fpHead = fpHead;
	}

	@Column(name = "step",length = 20)
	public String getStep() {
		return step;
	}

	public void setStep(String step) {
		this.step = step;
	}
}
